package j05zuoye;

import java.util.Random;

/*
教师类
定义一个教师类，教师包含工号（num）和工资（salary）两个属性。定义一个数组，保存10名教师的信息。教师的编号从100开始，教师的工资是[8k, 15k]之间的一个数。打印出薪资是12k的教师的信息。
 */
class Teacher{
    int num;
    //单位k
    int salary;

    public void sayInfo() {
        String info = "Teacher{" +
                "num=" + num +
                ", salary=" + salary +
                '}';
        System.out.println("info = " + info);
    }
}

public class J2teacher {
    public static void main(String[] args) {
        Random r = new Random();
        // [null,null,null....null]
        //new了十个空壳，用于未来存储teacher
        Teacher[] teacherArr = new Teacher[10];

//        teacherArr[0] = new Teacher();
//        teacherArr[0].num = 4;
        //初始化老师
        for (int i = 0; i < teacherArr.length; i++) {
            teacherArr[i] = new Teacher();
            teacherArr[i].num = 100+i;
            teacherArr[i].salary = r.nextInt(15-8+1)+8;

            // 判断薪资是否是12
            if(teacherArr[i].salary==12){
                //打印信息
//                System.out.println("teacherArr[i].num = " + teacherArr[i].num);
//                System.out.println("teacherArr[i].salary = " + teacherArr[i].salary);
                teacherArr[i].sayInfo();
            }
        }
        System.out.println("===");
        for (int i = 0; i < teacherArr.length; i++) {
//            System.out.println("teacherArr[i].num = " + teacherArr[i].num);
//            System.out.println("teacherArr[i].salary = " + teacherArr[i].salary);
            teacherArr[i].sayInfo();
        }
    }
}


class Test{
    public static void main(String[] args) {
        Teacher[] arr = new Teacher[10];


    }
}